package com.example.administrator.test;

import android.content.Intent;
import android.os.CountDownTimer;
import android.os.Handler;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class LogoActivity extends AppCompatActivity {
    Button button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_logo);
        ActionBar bar = getSupportActionBar();
        if(bar!=null){
            bar.hide();
        }
        Integer time = 5000;
//        Handler handler = new Handler();
//        handler.postDelayed(new Runnable() {
//            @Override
//            public void run() {
//                //Activity页面跳转
//                Intent intent = new Intent(LogoActivity.this,LoginActivity.class);
//                startActivity(intent);
//                //关闭自身
//                finish();
//            }
//        },time);
        button = (Button)findViewById(R.id.logo_button);

        final CountDownTimer timer;
        timer = new CountDownTimer(time,1000)
        {
            public void onFinish()
            {
                Intent intent = new Intent(LogoActivity.this,Slider3Activity.class);
                startActivity(intent);
                finish();
            }
            public void onTick(long millisUntilFinished)
            {
                button.setText(millisUntilFinished/1000+"跳过");
            }
        }.start();

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                timer.cancel();
                Intent intent = new Intent(LogoActivity.this,Slider3Activity.class);
                startActivity(intent);
                finish();
            }
        });

    }
}
